package com.java.action;

import java.util.ArrayList;
import java.util.List;

import com.java.pojo.ComEmp;
import com.java.service.IEmpService;
import com.java.service.IRoleService;
import com.sun.org.apache.bcel.internal.generic.NEW;

public class EmpRoleAction {
	private static  int PAGEROW = 5;
	private IEmpService empservice;
	private IRoleService roleservice;
	private List<ComEmp> emplist;
	private List<List<String>> rolelist=new ArrayList<List<String>>();

	private int page=1;
	private int message;
	
	private int endpage;
	private List<String> dept=new ArrayList<String>();

	public String execute() {
		
		int rowCount = empservice.getEmpNum();
		endpage = (rowCount % PAGEROW == 0) ? (rowCount / PAGEROW)
				: (rowCount / PAGEROW + 1);
		int start = (page - 1) * PAGEROW;
		emplist = empservice.getEmpListByPage(start, PAGEROW);
		for(ComEmp emp:emplist){
			System.out.println("test"+emp.getEDeptno());
			String deptname = roleservice.getDeptNameById(emp.getEDeptno());
//			System.out.println("222"+deptname);
			
			List <String> rlist = roleservice.getRoleByEmpno(emp.getEId());
//			System.out.println(rlist.size()+emp.getEName());
			rolelist.add(rlist);
//			System.out.println(deptname);
			dept.add(deptname);
		}
		System.out.println("size"+emplist.size());
		System.out.println("dept"+dept.size());
		return "success";
	}

	public int getMessage() {
		return message;
	}

	public void setMessage(int message) {
		this.message = message;
	}

	public List<List<String>> getRolelist() {
		return rolelist;
	}

	public List<String> getDept() {
		return dept;
	}

	public void setRoleservice(IRoleService roleservice) {
		this.roleservice = roleservice;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public List<ComEmp> getEmplist() {
		return emplist;
	}

	public int getEndpage() {
		return endpage;
	}

	public void setEmpservice(IEmpService empservice) {
		this.empservice = empservice;
	}
}
